The present invention relates generally to digital data manipulation. In particular, it relates to methods of using software to identify data overflow or underflow. Digital devices have proliferated widely in virtually all areas of technology during the last half century. Data in digital devices is often temporarily stored in blocks such as bytes or words including several individual bits. Such temporary storage is often limited by the size of the registers or other digital storage devices used in hardware. For example, some registers are designed to store a single byte. Where a register is used to store a number, there is a limit to the magnitude (upper or lower bounds) of the number that can be accurately stored. When the upper or lower bounds are exceeded, an overflow (upper bound) or underflow (lower bound) can occur.
In some systems, the hardware is equipped with overflow and/or underflow detection circuitry. In some cases, an overflow flag is set to indicate when a stored value exceeds its upper limit, and an underflow flag is set when a value exceeds its lower limit. The individual flags must typically be polled to determine whether a flag has been set. In other systems, overflow or underflow may be indicated by exceptions or interrupts, which often require special routines for acknowledgement and response. Because overflow or underflow interrupts occur rarely in most applications, testing and troubleshooting procedures for some hardware systems are difficult to implement and often inadequate. Further, multiple interrupt handlers-(used when more than one interrupt occurs in a short time) can be quite complex and are often difficult to design and test.
Still other systems use double length memory libraries or protocols to handle data overflow or underflow. For example, an 8-bit number could be stored in a 16 bit register, and the upper byte (the upper 8 bits) could be polled or monitored to determine whether an overflow or underflow has occurred in the lower byte. Such a protocol, in effect, uses an extra memory location for a variable in order to compensate for a hardware limitation. Further, in some hardware and operating systems, it may not be possible to directly manipulate a double length memory, at least without special coding. When the hardware and operating system can manipulate a double length memory with special coding, the use of the special coding may increase the computational load and the likelihood of program or hardware error. These difficulties and inefficiencies can be further compounded when a data element that is subject to potential overflow is of the largest built-in or standard data type allowed in the hardware. For example, if the largest register in a system is 32 bits, it can be cumbersome to create a data element having more than 32 bits to help prevent data overflow or underflow.